<?php

/**
 * My Application bootstrap file.
 */
use Nette\Diagnostics\Debugger,
    Nette\Application\Routers\Route;

// Load Nette Framework
require LIBS_DIR . '/Nette/loader.php';

// Enable Nette Debugger for error visualisation & logging
Debugger::$logDirectory = __DIR__ . '/../log';
Debugger::$strictMode = false;
Debugger::enable(Debugger::DEVELOPMENT);

//if (substr_count($_SERVER['HTTP_HOST'], 'povoden.com') > 0) Environment::setMode(Environment::PRODUCTION);
//Debugger::enable();

// Configure application
$configurator = new Nette\Config\Configurator;
$configurator->setTempDirectory(__DIR__ . '/../temp');

// Enable RobotLoader - this will load all classes automatically
$configurator->createRobotLoader()
	->addDirectory(APP_DIR)
	->addDirectory(LIBS_DIR)
	->register();

// Create Dependency Injection container from config.neon file
$configurator->addConfig(__DIR__ . '/config/config.neon');
$container = $configurator->createContainer();

//ini_set("session.gc_maxlifetime", "10800");
// Opens already started session
if (!$container->session->exists()) {
	$container->session->start();
}
ini_set("session.gc_maxlifetime", "10800");
// Setup router
$router = $container->router;
$router[] = new Route('index.php', 'Povoden:default', Route::ONE_WAY);
//$router[] = new Route('<presenter>/<action>[/<id>]', 'Povoden:default');
$router[] = new Route('<presenter=Povoden>/<action>[/<id>]', 'Povoden:default');
$router[] = new Route('<presenter=Forum>[/<id>]', 'Forum:default');
$router[] = new Route('<presenter=Admin>/<action>[/<id>]', 'Admin:default');
//$router[] = new Route('<presenter=Povoden>/<action=default>');

//Nette\Extras\Captcha::register();
//Nette\Forms\Container::extensionMethod('addCaptcha', array('Captcha', 'addCaptcha'));

Nette\Forms\Form::extensionMethod('Nette\Forms\Form::addSuggestInput', 'SuggestInput::addSuggestInput');

Nette\Forms\Container::extensionMethod('addDateTimePicker', function (Nette\Forms\Container $container, $name, $label = NULL) {
    return $container[$name] = new Extras\Forms\DateTimePicker($label);
});

// Configure and run the application!
$application = $container->application;
$application->catchExceptions = FALSE;
//$application->catchExceptions = TRUE;
$application->errorPresenter = 'Error';
$application->run();
